We start by loading in our data tables
require(mgcv)
bologna <- read.csv("bologna_full.csv")
bologna <- na.omit(bologna)
modena <- read.csv("modena_full.csv")
modena <- na.omit(modena)
florence <- read.csv("florence_full.csv")
florence <- na.omit(florence)
rome <- read.csv("rome_full.csv")
rome <- na.omit(rome)
num_iter <- 30
First lets look at effects of NPI
Bologna:
for(i in 0:num_iter) {
num_lag <- i
bologna <- read.csv("bologna_full.csv")
bologna$Daily.1 <- c(bologna$Daily[(1+num_lag):(nrow(bologna))], rep(NA, num_lag))
bologna <- na.omit(bologna)
infections.gam <- gam(Daily.1 ~ s(NPI, k=5), family=poisson(link="log"), data=bologna)
plot(infections.gam,scale=0,se=2, shade=TRUE,pages=1)
title(main = i)
summary(infections.gam)
print(cat("Day:", i, "R-sq", summary(infections.gam)$r.sq))
}
Modena:
for(i in 0:num_iter) {
num_lag <- i
modena <- read.csv("modena_full.csv")
modena$Daily.1 <- c(modena$Daily[(1+num_lag):(nrow(modena))], rep(NA, num_lag))
modena <- na.omit(modena)
infections.gam <- gam(Daily.1 ~ s(NPI, k=5), family=poisson(link="log"), data=modena)
plot(infections.gam,scale=0,se=2, shade=TRUE,pages=1)
title(main = i)
summary(infections.gam)
print(cat("Day:", i, "R-sq", summary(infections.gam)$r.sq))
}
Florence:
for(i in 0:num_iter) {
num_lag <- i
florence <- read.csv("florence_full.csv")
florence$Daily.1 <- c(florence$Daily[(1+num_lag):(nrow(florence))], rep(NA, num_lag))
florence <- na.omit(florence)
infections.gam <- gam(Daily.1 ~ s(NPI, k=5), family=poisson(link="log"), data=florence)
plot(infections.gam,scale=0,se=2, shade=TRUE,pages=1)
title(main = i)
summary(infections.gam)
print(cat("Day:", i, "R-sq", summary(infections.gam)$r.sq))
}
Rome:
for(i in 0:num_iter) {
num_lag <- i
rome <- read.csv("rome_full.csv")
rome$Daily.1 <- c(rome$Daily[(num_lag+1):(nrow(rome))], rep(NA, num_lag))
rome <- na.omit(rome)
infections.gam <- gam(Daily.1 ~ s(NPI, k=5), family=poisson(link="log"), data=rome)
plot(infections.gam,scale=0,se=2, shade=TRUE,pages=1)
title(main = i)
print(cat("Day:", i, "R-sq", summary(infections.gam)$r.sq))
}
Now lets look at Temp/Humidity
Bologna:
for(i in 0:num_iter) {
num_lag <- i
bologna <- read.csv("bologna_full.csv")
bologna$Daily.1 <- c(bologna$Daily[(1+num_lag):(nrow(bologna))], rep(NA, num_lag))
bologna <- na.omit(bologna)
infections.gam <- gam(Daily.1 ~ s(Temperature) + s(Humidity), family=poisson(link="log"), data=bologna)
plot(infections.gam,scale=0,se=2, shade=TRUE,pages=1)
title(main = i)
summary(infections.gam)
print(cat("Day:", i, "R-sq", summary(infections.gam)$r.sq))
}
Day: 0 R-sq 0.4896344NULL
Day: 1 R-sq 0.4633273NULL
Day: 2 R-sq 0.4918461NULL
Day: 3 R-sq 0.5703598NULL
Day: 4 R-sq 0.5318496NULL
Day: 5 R-sq 0.4716657NULL
Day: 6 R-sq 0.4663372NULL
Day: 7 R-sq 0.5765711NULL
Day: 8 R-sq 0.5500971NULL
Day: 9 R-sq 0.5945654NULL
Day: 10 R-sq 0.6034324NULL
Day: 11 R-sq 0.591467NULL
Day: 12 R-sq 0.6489848NULL
Day: 13 R-sq 0.6266869NULL
Day: 14 R-sq 0.6410671NULL
Day: 15 R-sq 0.6286455NULL
Day: 16 R-sq 0.6710816NULL
Day: 17 R-sq 0.6710324NULL
Day: 18 R-sq 0.6733654NULL
Day: 19 R-sq 0.7549484NULL
Day: 20 R-sq 0.7704205NULL
Day: 21 R-sq 0.7335032NULL
Day: 22 R-sq 0.6961922NULL
Day: 23 R-sq 0.7280413NULL
Day: 24 R-sq 0.7578183NULL
Day: 25 R-sq 0.7361595NULL
Day: 26 R-sq 0.6891041NULL
Day: 27 R-sq 0.6511969NULL
Day: 28 R-sq 0.6365822NULL
Day: 29 R-sq 0.617207NULL
Day: 30 R-sq 0.5663472NULL
Modena:
for(i in 0:num_iter) {
num_lag <- i
modena <- read.csv("modena_full.csv")
modena$Daily.1 <- c(modena$Daily[(1+num_lag):(nrow(modena))], rep(NA, num_lag))
modena <- na.omit(modena)
infections.gam <- gam(Daily.1 ~ s(Temperature) + s(Humidity), family=poisson(link="log"), data=modena)
plot(infections.gam,scale=0,se=2, shade=TRUE,pages=1)
title(main = i)
summary(infections.gam)
print(cat("Day:", i, "R-sq", summary(infections.gam)$r.sq))
}
Day: 0 R-sq 0.5380692NULL
Day: 1 R-sq 0.4603939NULL
Day: 2 R-sq 0.5502608NULL
Day: 3 R-sq 0.5257741NULL
Day: 4 R-sq 0.495446NULL
Day: 5 R-sq 0.412964NULL
Day: 6 R-sq 0.4962353NULL
Day: 7 R-sq 0.553577NULL
Day: 8 R-sq 0.5091717NULL
Day: 9 R-sq 0.4840658NULL
Day: 10 R-sq 0.6148442NULL
Day: 11 R-sq 0.6935744NULL
Day: 12 R-sq 0.601654NULL
Day: 13 R-sq 0.6328875NULL
Day: 14 R-sq 0.6602823NULL
Day: 15 R-sq 0.6418581NULL
Day: 16 R-sq 0.7038114NULL
Day: 17 R-sq 0.6879685NULL
Day: 18 R-sq 0.6928742NULL
Day: 19 R-sq 0.7349044NULL
Day: 20 R-sq 0.6730137NULL
Day: 21 R-sq 0.6289489NULL
Day: 22 R-sq 0.6293349NULL
Day: 23 R-sq 0.5951238NULL
Day: 24 R-sq 0.6252658NULL
Day: 25 R-sq 0.691863NULL
Day: 26 R-sq 0.5791828NULL
Day: 27 R-sq 0.5838233NULL
Day: 28 R-sq 0.5648786NULL
Day: 29 R-sq 0.6451174NULL
Day: 30 R-sq 0.6263023NULL
Florence:
for(i in 0:num_iter) {
num_lag <- i
florence <- read.csv("florence_full.csv")
florence$Daily.1 <- c(florence$Daily[(1+num_lag):(nrow(florence))], rep(NA, num_lag))
florence <- na.omit(florence)
infections.gam <- gam(Daily.1 ~ s(Temperature) + s(Humidity), family=poisson(link="log"), data=florence)
plot(infections.gam,scale=0,se=2, shade=TRUE,pages=1)
title(main = i)
summary(infections.gam)
print(cat("Day:", i, "R-sq", summary(infections.gam)$r.sq))
}
Day: 0 R-sq 0.4728276NULL
Day: 1 R-sq 0.3744223NULL
Day: 2 R-sq 0.4542527NULL
Day: 3 R-sq 0.5526952NULL
Day: 4 R-sq 0.4970105NULL
Day: 5 R-sq 0.4053944NULL
Day: 6 R-sq 0.3662819NULL
Day: 7 R-sq 0.6391539NULL
Day: 8 R-sq 0.664867NULL
Day: 9 R-sq 0.6566028NULL
Day: 10 R-sq 0.5371588NULL
Day: 11 R-sq 0.5609689NULL
Day: 12 R-sq 0.5139698NULL
Day: 13 R-sq 0.4925803NULL
Day: 14 R-sq 0.4693117NULL
Day: 15 R-sq 0.5636821NULL
Day: 16 R-sq 0.6640505NULL
Day: 17 R-sq 0.6977326NULL
Day: 18 R-sq 0.5019629NULL
Day: 19 R-sq 0.5811804NULL
Day: 20 R-sq 0.6194071NULL
Day: 21 R-sq 0.5790887NULL
Day: 22 R-sq 0.5453216NULL
Day: 23 R-sq 0.6266673NULL
Day: 24 R-sq 0.5540829NULL
Day: 25 R-sq 0.6299241NULL
Day: 26 R-sq 0.6185027NULL
Day: 27 R-sq 0.5877647NULL
Day: 28 R-sq 0.5080166NULL
Day: 29 R-sq 0.6840771NULL
Day: 30 R-sq 0.7033451NULL
Rome:
for(i in 0:num_iter) {
num_lag <- i
rome <- read.csv("rome_full.csv")
rome$Daily.1 <- c(rome$Daily[(num_lag+1):(nrow(rome))], rep(NA, num_lag))
rome <- na.omit(rome)
infections.gam <- gam(Daily.1 ~ s(Temperature) + s(Humidity), family=poisson(link="log"), data=rome)
plot(infections.gam,scale=0,se=2, shade=TRUE,pages=1)
title(main = i)
print(cat("Day:", i, "R-sq", summary(infections.gam)$r.sq))
}
Day: 0 R-sq 0.4202767NULL
Day: 1 R-sq 0.4343473NULL
Day: 2 R-sq 0.4526714NULL
Day: 3 R-sq 0.4636081NULL
Day: 4 R-sq 0.4757067NULL
Day: 5 R-sq 0.5211681NULL
Day: 6 R-sq 0.5508436NULL
Day: 7 R-sq 0.5854002NULL
Day: 8 R-sq 0.6340703NULL
Day: 9 R-sq 0.6287562NULL
Day: 10 R-sq 0.5980017NULL
Day: 11 R-sq 0.6214937NULL
Day: 12 R-sq 0.6830744NULL
Day: 13 R-sq 0.7555303NULL
Day: 14 R-sq 0.7050403NULL
Day: 15 R-sq 0.7038004NULL
Day: 16 R-sq 0.7667924NULL
Day: 17 R-sq 0.806356NULL
Day: 18 R-sq 0.7858903NULL
Day: 19 R-sq 0.7727713NULL
Day: 20 R-sq 0.7579232NULL
Day: 21 R-sq 0.774631NULL
Day: 22 R-sq 0.7890732NULL
Day: 23 R-sq 0.7949118NULL
Day: 24 R-sq 0.7691577NULL
Day: 25 R-sq 0.7223769NULL
Day: 26 R-sq 0.7041938NULL
Day: 27 R-sq 0.7103775NULL
Day: 28 R-sq 0.7876148NULL
Day: 29 R-sq 0.7265889NULL
Day: 30 R-sq 0.7234478NULL